<template>
  <div ref="target" class="home-new">
   <transition name="fade">
      <HomePanel title="新鲜好物" sub-title="新鲜出炉 品质靠谱">
      <template #right><XtxMore path="/" /></template>
      <!-- 面板内容 -->
      <ul class="goods-list">
        <template v-if="goods">
            <li v-for="item in goods" :key="item.id">
          <RouterLink   :to="`/login?id=${item.id}`">
            <img :src="item.picture" alt="">
            <p class="name ellipsis">{{item.name}}</p>
            <p class="price">&yen;{{item.price}}</p>
          </RouterLink>

        </li>
        </template>
<div v-else>
    <skeleton class="HomeNewgujia"   bg="rgba(225, 225, 225,0.8)" />
</div>
      </ul>

    </HomePanel>
   </transition>

  </div>
</template>
<script>
import HomePanel from './home-pannel.vue'
import { findNew } from '@/api/home'
import { useLazyData } from './index'
export default {
  name: 'HomeNew',
  components: { HomePanel },
  setup () {
    const { target, result: goods } = useLazyData(findNew)
    return { goods, target }
  }
}
</script>
<style scoped lang="less">
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
&:hover{
transition: all .5s;
box-shadow:5px 5px 5px 5px rgb(204, 200, 200);
};
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }
}
.xtx-skeleton {
  animation: fade .5s linear infinite alternate;
}
@keyframes fade {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 1;
  }
}
.fade {
  &-leave{
     opacity: 1;
    &-active{
      transition: all 1s;
    }
    &-to{
       opacity: 0;
    }
  }
}
</style>
